package com.cqs.learning.spring.cloud.producer.service;

import com.cqs.learning.spring.cloud.producer.event.ConfigEvent;
import lombok.extern.log4j.Log4j2;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

/**
 * @author lixw
 * @date created in 17:48 2020/5/4
 */
@Log4j2
@Component
public class ConfigListener implements ApplicationListener<ConfigEvent> {

    @Override
    public void onApplicationEvent(ConfigEvent event) {
        //直接返回最新得配置文件
        log.info("处理修改文件事件" + event.getSource());
        ConfigService.ReadConfigTask source = (ConfigService.ReadConfigTask) event.getSource();
        source.generateResponse();
    }
}
